package patternmining.model.graph.bpsl;

import patternmining.model.graph.Edge;

public class BpslPredicate extends Edge {

    public BpslPredicate(BpslVariable origin, BpslVariable destination){
        super(origin, destination);
    }

    public static boolean acceptsArguments( String predicateLiteral, BpslVariable firstArg, BpslVariable secondArg){
        
        if( predicateLiteral.equals( "Defined-in" ) ) return BpslDefined_In.acceptsArguments(firstArg, secondArg);

        if( predicateLiteral.equals( "Reference-to-many" ) ) return BpslReference_to_Many.acceptsArguments(firstArg, secondArg);

        if( predicateLiteral.equals( "Reference-to-one" ) ) return BpslReference_to_One.acceptsArguments(firstArg, secondArg);

        if( predicateLiteral.equals( "Inheritance" ) ) return BpslInheritance.acceptsArguments(firstArg, secondArg);

        if( predicateLiteral.equals( "Creation" ) ) return BpslCreation.acceptsArguments(firstArg, secondArg);

        if( predicateLiteral.equals( "Invocation" ) ) return BpslInvocation.acceptsArguments(firstArg, secondArg);

        if( predicateLiteral.equals( "Argument" ) ) return BpslArgument.acceptsArguments(firstArg, secondArg);

        if( predicateLiteral.equals( "Return-type" ) ) return BpslReturnType.acceptsArguments(firstArg, secondArg);

        return false;
    }

    public static BpslPredicate getPredicate(String predicateLiteral, BpslVariable firstArg, BpslVariable secondArg){

        if( predicateLiteral.equals( "Defined-in" ) )           return new BpslDefined_In(firstArg, secondArg);

        if( predicateLiteral.equals( "Reference-to-many" ) )    return new BpslReference_to_Many(firstArg, secondArg);

        if( predicateLiteral.equals( "Reference-to-one" ) )     return new BpslReference_to_One(firstArg, secondArg);

        if( predicateLiteral.equals( "Inheritance" ) )          return new BpslInheritance(firstArg, secondArg);

        if( predicateLiteral.equals( "Creation" ) )             return new BpslCreation(firstArg, secondArg);

        if( predicateLiteral.equals( "Invocation" ) )           return new BpslInvocation(firstArg, secondArg);

        if( predicateLiteral.equals( "Argument" ) )             return new BpslArgument(firstArg, secondArg);

        if( predicateLiteral.equals( "Return-type" ) )          return new BpslReturnType(firstArg, secondArg);

        return null;
    }
	 
}
 
